package com.amigo.online.provider.video.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.amigo.online.common.param.result.AdvHomePageInfo;

@Mapper
public interface AdvHomeMapper {

    @Select("select c.id, a.url, c.ios_forward_url as ios, c.android_forward_url as android from adv_home_source_tbl a,"
            + " (select adv_id,min(abs(ratio - #{ratio})) as ratio from adv_home_tbl GROUP BY adv_id) b, adv_home_apply_tbl c"
            + " where a.adv_id = b.adv_id and abs(a.ratio - #{ratio}) = b.ratio and c.id = a.id order by a.adv_id limit 3")
    List<AdvHomePageInfo> findHomeAdvByRatio(double ratio);

    @Select("select b.id,a.url,b.ios_forward_url as ios ,b.android_forward_url as android from adv_home_source_tbl a,"
            + " adv_home_apply_tbl b where a.adv_id = b.id and a.type = 0 limit 3")
    List<AdvHomePageInfo> findHomeDefaultAdv();

}
